<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" layout:decorate="main"
      xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro" >
    <head >
        <title >资源管理</title >
        <link th:href="@{../localcss/crmlist.css}" href="../../static/localcss/crmlist.css" rel="stylesheet" >
        <link th:href="@{../css/treetable/jquery.treetable.min.css}" href="../../static/css/treetable/jquery.treetable.min.css" rel="stylesheet" >
        <link th:href="@{../css/treetable/jquery.treetable.theme.default.min.css}" href="../../static/css/treetable/jquery.treetable.theme.default.min.css" rel="stylesheet" >
        
    </head >
    <body >
        <div layout:fragment="content" >
            <div class="" >
                <div class="clearfix" ></div >
                <div class="row" >
                    <div class="col-md-12" >
                        <div class="x_panel" >
                            <div class="x_title" >
                                <h2 >
                                    资源管理 <i class="fa fa-user" ></i >
                                    <small >
                                        - 您可以通过搜索或者其他的筛选项对资源的信息进行编辑、删除等管理操作。^_^
                                    </small >
                                </h2 >
                                <div class="clearfix" ></div >
                            </div >
                            <div class="x_content" >
                                <form method="post" action="/right/list" th:action="@{/right/list}" >
                                    <input type="hidden" name="pageIndex" value="1" />
                                    <ul >
                                        <li >
                                            <div class="form-group" >
                                                <label class="control-label col-md-3 col-sm-3 col-xs-12" >用户名称</label >
                                                <div class="col-md-6 col-sm-6 col-xs-12" >
                                                    <input name="usrName" type="text" th:value="${usrName}"
                                                           class="form-control col-md-6 col-xs-12" value="" >
                                                </div >
                                            </div >
                                        </li >
                                        <li >
                                            <div class="form-group" >
                                                <label class="control-label col-md-3 col-sm-3 col-xs-12" >类型</label >
                                                <div class="col-md-6 col-sm-6 col-xs-12" >
                                                    <select name="roleId" id="roleId" class="form-control" >
                                                        <option value="0" >--请选择--</option >
                                                        <option th:selected="${role.roleId eq roleId}" th:each="role:${roles}"
                                                                th:value="${role.roleId}" th:text="${role.roleName}" value="" >
                                                            角色1
                                                        </option >
                                                    </select >
                                                </div >
                                            </div >
                                        </li >
                                        <li >
                                            <button type="submit" class="btn btn-primary" > 查&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;询
                                            </button >
                                        </li >
                                    </ul >
                                </form >
                            </div >
                        </div >
                    </div >
                    <div class="col-md-12 col-sm-12 col-xs-12" >
                        <div class="x_panel" >
                            <div class="x_content" >
                                <p class="text-muted font-13 m-b-30" ></p >
                                <div id="datatable-responsive_wrapper"
                                     class="dataTables_wrapper form-inline dt-bootstrap no-footer" >
                                    <div class="row" >
                                        <div class="col-sm-12" >
                                            <a href="/right/add" th:href="@{http://localhost:81/right/add}" class="btn btn-success btn-sm"  >新增资源信息</a >
                                            <table id="datatable-responsive"
                                                   class="table table-striped table-bordered dt-responsive nowrap dataTable no-footer dtr-inline collapsed"
                                                   cellspacing="0" width="100%" role="grid"
                                                   aria-describedby="datatable-responsive_info" style="width: 100%;" >
                                                <thead >
                                                <tr role="row" >
                                                    <th class="sorting_asc" tabindex="0"
                                                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                        aria-label="First name: activate to sort column descending"
                                                        aria-sort="ascending" >编号
                                                    </th >
                                                    <th class="sorting" tabindex="0"
                                                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                        aria-label="Last name: activate to sort column ascending" >
                                                        上级
                                                    </th >
                                                    <th class="sorting" tabindex="0"
                                                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                        aria-label="Last name: activate to sort column ascending" >
                                                        类型
                                                    </th >
                                                    <th class="sorting" tabindex="0"
                                                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                        aria-label="Last name: activate to sort column ascending" >
                                                        名称
                                                    </th >
                                                    <th class="sorting" tabindex="0"
                                                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                        aria-label="Last name: activate to sort column ascending" >
                                                        资源路径
                                                    </th >
                                                    <th class="sorting" tabindex="0"
                                                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                        aria-label="Last name: activate to sort column ascending" >
                                                        简称
                                                    </th >
                                                    <th class="sorting" tabindex="0"
                                                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                        aria-label="Last name: activate to sort column ascending" >
                                                        操作
                                                    </th >
                                                </tr >
                                                </thead >
                                                <tbody >
                                                <tr role="row" class="odd" th:each="temp:${rightPage}"  th:data-tt-id="${temp.rightCode}"  th:data-tt-parent-id="${temp.rightParentCode}">
                                                    <td tabindex="0" class="sorting_1" th:text="${temp.rightCode}" >rightCode</td >
                                                    <td th:text="${temp.rightParentCode}" >rightParentCode</td >
                                                    <td th:text="${temp.rightType}" >rightType</td >
                                                    <td th:text="${temp.rightText}" >rightText</td >
                                                    <td th:text="${temp.rightUrl}" >rightUrl</td >
                                                    <td th:text="${temp.rightTip}" >rightTip</td >
                                                    <td >
                                                        <div class="btn-group" >
                                                            <button type="button" class="btn btn-danger" >点击操作</button >
                                                            <button type="button" class="btn btn-danger dropdown-toggle"
                                                                    data-toggle="dropdown" aria-expanded="false" >
                                                                <span class="caret" ></span >
                                                                <span class="sr-only" >Toggle Dropdown</span >
                                                            </button >
                                                            <ul class="dropdown-menu" role="menu" >
                                                                <li ><a class="editInfo"
                                                                        href="/user/edit?usrId=1"
                                                                        th:href="@{/right/edit(id=${temp.rightCode})}"
                                                                        data-toggle="tooltip"
                                                                        data-placement="top" title=""
                                                                        data-original-title="编辑" >编辑</a >
                                                                </li >
                                                                <li ><a class="delInfo" id="del" href="#"
                                                                        th:onclick="doDel(this,[[${temp.rightCode}]])"
                                                                        data-toggle="tooltip" data-placement="top" title=""
                                                                        data-original-title="删除" >删除</a ></li >
                                                            </ul >
                                                        </div >
                                                    </td >
                                                </tr >
                                                </tbody >
                                            </table >
                                        </div >
                                    </div >
                                    
                                </div >
                            </div >
                        </div >
                    </div >
                </div >
            </div >
        </div >
    </body >
    <script layout:fragment="js" >
        function doDel(obj, rightCode) {
            if (confirm("你确定需要删除该资源信息吗？")) {
                $.ajax({
                    type: "GET",
                    url: "/right/del/" + rightCode,
                    /*data: {
                        "usrId": usrId
                    },*/
                    dataType: "json",
                    success: function (data) {
                        if (data.delResult == "true") { // 删除成功：移除删除行
                            alert("删除成功！");
                            $(obj).parents("tr").remove();
                        }
                    },
                    error: function (data) {
                        alert("对不起，删除失败！");
                    }
                });
            }
        }

        $("#datatable-responsive").treetable({ expandable: true });
        /*$(document).ready(function(){
            $.ajax({
                type:"GET",
                url:"${pageContext.request.contextPath}/role/json",
                dataType:"json",
                success:function(data){
                    $.each(data, function(i, tmp) {
                        $("#roleId").append(
                            "<option value='"+tmp.roleId+"'>" + tmp.roleName + "</option>");
                    });
                },
                error:function(data){
                    alert("对不起，获取数据失败！");
                }
            });
        });*/
    </script >
</html >